package com.worldtolearn.offer.bu;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import com.worldtolearn.offer.dao.ActivityDao;
import com.worldtolearn.offer.entity.Activity;

@Named
public class ActivityBu implements IActivityBu, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Inject
	ActivityDao activityDao;

	@Override
	public void createActivity(Activity activity) {
		activityDao.createActivity(activity);

	}

	@Override
	public void deleteActivity(Activity activity) {
		activityDao.deleteActivity(activity);

	}

	@Override
	public List<Activity> getAllActivity() {
		return activityDao.getAllActivity();
	}

	@Override
	public List<Activity> getActivityByLabelActivity(String labelActivity) {
		return activityDao.getActivityByLabelActivity(labelActivity);
	}

	@Override
	public List<String> getDistinctsActivity() {
		List<Activity> list = new ArrayList<Activity>();
		List<String> list2 = new ArrayList<String>();
		String activity;
		list = getAllActivity();
		for(Activity a : list){
			activity = a.getLabelActivity();
			if(!list2.contains(activity)){
				list2.add(activity);
			}
		}
		return list2;
	}

}
